package com.zhou.JavaAndroidFirm.http;

import java.util.ArrayList;
import java.util.List;

import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;

/**
 * @author Administrator
 * @date 2018/7/16 0016
 * @des
 */
public final class SimpleCookieJar implements CookieJar {
    private List<Cookie> allCookie = new ArrayList<>();

    @Override
    public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
        allCookie.addAll(cookies);
    }

    @Override
    public List<Cookie> loadForRequest(HttpUrl url) {
        List<Cookie> result = new ArrayList<>();
        for (Cookie cookie : result
                ) {
            if (cookie.matches(url)) {
                result.add(cookie);
            }
        }
        return result;
    }
}
